import api from './index'


/**
 * 获取收藏的文章列表
 */
export function getCollectArticleList(page) {
    console.log("collect getCollectArticleList")
    return api.getCollectAtricleList(page).then((response) => {
        console.log("collect getCollectArticleList data = ", JSON.stringify(response))
        return Promise.resolve(JSON.parse(response.data).data)
    }).catch((err) => {
        return Promise.reject(err)
    })
}

/**
 * 收藏文章
 */
export function collectArticle(id) {
    console.log("collect collectArticle")
    return api.collectArticle(id).then((response) => {
        console.log("collect collectArticle data = ", JSON.stringify(response))
        return Promise.resolve(JSON.parse(response.data).data)
    }).catch((err) => {
        return Promise.reject(err)
    })
}

/**
 * 取消文章收藏
 */
export function unCollectArticle(id) {
    console.log("collect unCollectArticle")
    return api.unCollectArticle(id).then((response) => {
        console.log("collect unCollectArticle data = ", JSON.stringify(response))
        return Promise.resolve(JSON.parse(response.data).data)
    }).catch((err) => {
        return Promise.reject(err)
    })
}
/**
 * 取消文章收藏
 */
export function unCollectArticleByOriginId(id,originId) {
    console.log("collect unCollectArticleByOriginId")
    return api.unCollectArticleByOriginId(id,originId).then((response) => {
        console.log("collect unCollectArticleByOriginId data = ", JSON.stringify(response))
        return Promise.resolve(JSON.parse(response.data).data)
    }).catch((err) => {
        return Promise.reject(err)
    })
}